//
//  File_System_Manager.h
//  LearningOops
//
//  Created by Swetha Patnala on 4/14/13.
//  Copyright (c) 2013 Swetha Patnala. All rights reserved.
//

#ifndef __LearningOops__File_System_Manager__
#define __LearningOops__File_System_Manager__

#define NUM_OF_INODES 60
#define NUM_OF_DATABLOCKS 4096
#define DATABLOCK_SIZE 4096

#include <iostream>

typedef struct {
    std::string file_system_name;
    int num_of_inodes;
    int num_of_datablocks;
    int num_of_unallocated_inodes;
    int num_of_unallocated_datablocks;
    int block_number_of_superblock ;
    int inode_counter;
    int datablock_counter;
} super_block_structure;


class File_System_Manager {
    
     

private:
    static File_System_Manager* Instance;
    super_block_structure* super_block;
    File_System_Manager();
    int inode_bitmap[NUM_OF_INODES];
    int data_bitmap[NUM_OF_DATABLOCKS];
    //File_System_Manager(const File_System_Manager& orig);
    Inode* inode_array[NUM_OF_INODES];
    char* datablock_array[NUM_OF_DATABLOCKS];
    
    
public:
    ~File_System_Manager();
    static File_System_Manager* getInstance();
    void printSuperBlock();
    int decrement_inodeblock_num();
    int decrement_datablock_num(int num_of_blocks);
    int increment_inodecounter();
    int get_inodecounter();
    bool is_inode_full();
    int assignValueToInodeBitmap();
    int assignValueToDataBitmap();
    int increment_datablock_counter();
    void printInodeBitMap();
     void printDataBitMap();
    int getFreeBitFromInodeBitmap();
    
    int getFreeDataBitFromDataBitmap();
    int make_fs(char* fileSystem);
    int mount_fs(char* fileSystem);
    int unmount_fs(char* fileSystem);
};



#endif /* defined(__LearningOops__File_System_Manager__) */
